﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ESpace.DalTools
{
	public partial class GetMD5 : Form
	{
		public GetMD5()
		{
			InitializeComponent();
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			this.Close();
		}

		private void btnOK_Click(object sender, EventArgs e)
		{
			txtLowerMD5.Text = GetMD5String(txtSource.Text).ToLower();
			txtUpperMD5.Text = GetMD5String(txtSource.Text).ToUpper();
		}

		private string GetMD5String(string SourceString)
		{
			byte[] b = System.Text.UTF8Encoding.Default.GetBytes(SourceString);
			b = new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(b);
			string strReturn = "";
			for (int i = 0; i < b.Length; i++)
				strReturn += b[i].ToString("x").PadLeft(2, '0');
			return strReturn;
		}
	}
}
